---
title: gluestack-ui Badge Component | Installation, Usage, and API

description: Add status indicators to your interface for clear, attention-grabbing usability cues, conveying crucial information swiftly.

pageTitle: Badge

pageDescription: Add status indicators to your interface for clear, attention-grabbing usability cues, conveying crucial information swiftly.

showHeader: true
---

import { Meta } from '@storybook/addon-docs';

<Meta title="with-nativewind/Components/Data Display/Badge" />

import {
  Center,
  Badge,
  BadgeText,
  BadgeIcon,
  Icon,
  Box,
  Text,
  VStack,
  HStack,
  SettingsIcon,
  AddIcon,
  Divider,
  Image,
  CheckIcon,
  Heading,
  Avatar,
  AvatarFallbackText,
  AvatarImage,
  Button,
  ButtonText,
  GlobeIcon,
} from '../../core-components/nativewind';

import {
  PaintBucket,
  PuzzleIcon,
  BadgeCheckIcon,
  BadgePlusIcon,
} from 'lucide-react-native';
import {
  AppProvider,
  CodePreview,
  Table,
  TableContainer,
  InlineCode,
  Tabs
} from '@gluestack/design-system';
import { transformedCode } from '../../utils';
import Wrapper from '../../core-components/nativewind/Wrapper';
import { CollapsibleCode } from '@gluestack/design-system';
import AnatomyImage from '../../extra-components/nativewind/AnatomyImage';

This is an illustration of **Badge** component.

<Wrapper>
  <CodePreview
    metaData={{
      code: `
        <Badge {...props}>
          <BadgeText>Verified</BadgeText>
          <BadgeIcon as={GlobeIcon} className="ml-2" />
        </Badge>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Badge,
        BadgeText,
        BadgeIcon,
        GlobeIcon
      },
      argsType: {
        size: {
          control: 'select',
          options: ['sm', 'md', 'lg'],
          default: 'md',
        },
        variant: {
          control: 'select',
          options: ['solid', 'outline'],
          default: 'solid',
        },
        action: {
          control: 'select',
          options: ['error', 'warning', 'success', 'info', 'muted'],
          default: 'success',
        },
      },
    }}
  />
</Wrapper>

<br />

## Installation

<Tabs value="cli" type="section">
  <Tabs.TabList>
      <Tabs.Tab value="cli">
        <Tabs.TabTitle>CLI</Tabs.TabTitle>
      </Tabs.Tab>
     <Tabs.Tab value="manual">
        <Tabs.TabTitle>Manual</Tabs.TabTitle>
     </Tabs.Tab>
  </Tabs.TabList>
  <Tabs.TabPanels>
    <Tabs.TabPanel value="cli">
<>

### Run the following command:
  ```bash
  npx gluestack-ui add badge
  ```
</>
    </Tabs.TabPanel>
    <Tabs.TabPanel value="manual"> 
<>

### Step 1: Copy and paste the following code into your project.
<CollapsibleCode>

```jsx 
%%-- File: core-components/nativewind/badge/index.tsx --%% 
```
</CollapsibleCode>

### Step 2: Update the import paths to match your project setup.
</>
    </Tabs.TabPanel>
  </Tabs.TabPanels>
</Tabs>

## API Reference

To use this component in your project, include the following import statement in your file.

```jsx
import { Badge } from '@/components/ui/badge';
```
<AnatomyImage mobileUrl='https://i.imgur.com/l1rzVbp.png' webUrl='https://i.imgur.com/H735cuy.png' classNameStyle='aspect-[513/341] md:aspect-[736/225]' />

```jsx
export default () => (
  <Badge>
    <BadgeText />
    <BadgeIcon />
  </Badge>
);
```

### Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

#### Badge

It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component.

#### BadgeText

It inherits all the properties of React Native's [Text](https://reactnative.dev/docs/text) component.

#### BadgeIcon

Contains all Icon related layout style props and actions. It inherits all the properties of gluestack Style's [AsForwarder](/style/docs/api/as-forwarder) component.

### Props

Badge component is created using View component from react-native. It extends all the props supported by [React Native View](https://reactnative.dev/docs/view#props).

#### Badge

<>
  <TableContainer>
    <Table>
      <Table.THead>
        <Table.TR>
          <Table.TH>
            <Table.TText>Name</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Value</Table.TText>
          </Table.TH>
          <Table.TH>
            <Table.TText>Default</Table.TText>
          </Table.TH>
        </Table.TR>
      </Table.THead>
      <Table.TBody>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>action</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>error | warning | success | info | muted</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>success</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>variant</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>solid | outline</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>solid</Table.TText>
          </Table.TD>
        </Table.TR>
        <Table.TR>
          <Table.TD>
            <Table.TText>
              <InlineCode>size</InlineCode>
            </Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>sm | md | lg</Table.TText>
          </Table.TD>
          <Table.TD>
            <Table.TText>md</Table.TText>
          </Table.TD>
        </Table.TR>
      </Table.TBody>
    </Table>
  </TableContainer>
</>

> Note: These props are exclusively applicable when utilizing the default configuration of gluestack-ui/config. If you are using a custom theme, these props may not be available.

### Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

#### Badge with Avatar

An example of the Badge component being used with the Avatar component to display badges alongside user avatars for enhanced visual representation or identification.

<Wrapper>
  <CodePreview
    showComponentRenderer={true}
    showArgsController={false}
    metaData={{
      code: `
        <VStack space="2xl">
          <HStack space="md">
            <Avatar>
              <AvatarFallbackText>SS</AvatarFallbackText>
              <AvatarImage
                source={{
                  uri: 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8dXNlcnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=800&q=60',
                }}
              />
            </Avatar>
            <VStack>
            <HStack>
              <Heading size="sm" >Ronald Richards</Heading>
              <Badge  size="sm" variant="solid"  action="success" className='ml-1'>
                  <BadgeText>Verified</BadgeText>
                  <BadgeIcon as={BadgeCheckIcon} className='ml-1'/>
              </Badge>
            </HStack>
            <Text size='sm' >Nursing Assistant</Text>
            </VStack>
          </HStack>
        </VStack>
      `,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Avatar,
        AvatarFallbackText,
        AvatarImage,
        Heading,
        Text,
        HStack,
        VStack,
        Badge,
        BadgeText,
        BadgeIcon,
        GlobeIcon,
        BadgeCheckIcon,
      },
      argsType: {},
    }}
  />
</Wrapper>

### Badge Composition

An example of the Badge component being used with the Composition component, allowing for the display of badges within a composition of other UI elements.

<Wrapper>
  <CodePreview
    showArgsController={false}
    metaData={{
      code: `
       <Box className='items-center'>
        <VStack>
          <Badge  
            className='z-10 self-end h-[22px] w-[22px] bg-red-600 rounded-full -mb-3.5 -mr-3.5'
            variant="solid"
          >
            <BadgeText className='text-white'>2</BadgeText>
          </Badge>
          <Button>
            <ButtonText>
              Notifications
            </ButtonText>
          </Button>
        </VStack>
    </Box>
`,
      transformCode: (code) => {
        return transformedCode(code);
      },
      scope: {
        Wrapper,
        Badge,
        BadgeText,
        BadgeIcon,
        GlobeIcon,
        Box,
        Text,
        HStack,
        VStack,
        Heading,
        Button,
        ButtonText,
      },
      argsType: {},
    }}
  />
</Wrapper>
